package com.ruoyi.system.mapper;

import java.util.List;

import com.ruoyi.system.domain.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

/**
 * 预警规则Mapper接口
 * 
 * @author ruoyi
 * @date 2021-06-19
 */
public interface WarningRuleMapper 
{
    /**
     * 查询预警规则
     * 
     * @param id 预警规则ID
     * @return 预警规则
     */
    public WarningRule selectWarningRuleById(Long id);

    /**
     * 查询预警规则列表
     * 
     * @param warningRule 预警规则
     * @return 预警规则集合
     */
    public List<WarningRule> selectWarningRuleList(WarningRule warningRule);

    /**
     * 新增预警规则
     * 
     * @param warningRule 预警规则
     * @return 结果
     */
    public int insertWarningRule(WarningRule warningRule);

    /**
     * 修改预警规则
     * 
     * @param warningRule 预警规则
     * @return 结果
     */
    public int updateWarningRule(WarningRule warningRule);

    /**
     * 删除预警规则
     * 
     * @param id 预警规则ID
     * @return 结果
     */
    public int deleteWarningRuleById(Long id);

    /**
     * 批量删除预警规则
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    public int deleteWarningRuleByIds(Long[] ids);

    public int batchRuleReceiver(List<RuleReceiver> list);

    public int batchRuleWarningNoticeType(List<RuleWarningNoticeType> list);

    public int batchRuleMediaType(List<RuleMediaType> list);

    public int batchRuleEmotion(List<RuleEmotion> list);

    public int  deleteRuleReceiverByRuleId(Long id);

    public int  deleteRuleWarningNoticeTypeByRuleId(Long id);

    public int  deleteRuleMediaTypeByRuleId(Long id);

    public int  deleteRuleEmotionByRuleId(Long id);

    public int   deleteRuleReceiver(Long[] ids);

    public int   deleteRuleWarningNoticeType(Long[] ids);

    public int   deleteRuleMediaType(Long[] ids);

    public int   deleteRuleEmotion(Long[] ids);

    @Select("select  a.*,b.nick_name  from rule_receiver a left join  warning_receiver b  on  a.receiver=b.id   where   a.rule_id= #{id}")
    @Results({
            @Result(column = "rule_id", property = "ruleId"),
            @Result(column = "nick_name", property = "receiverName"),
    })
    public List<RuleReceiver> getReceiverByruleId(@Param("id") Long id);

    @Select("select  a.*,b.dict_label  from rule_warning_notice_type a left join  sys_dict_data b  on a.warning_notice_type=b.dict_value  where   a.rule_id= #{id}")
    @Results({
            @Result(column = "rule_id", property = "ruleId"),
            @Result(column = "warning_notice_type", property = "warningNoticeType"),
            @Result(column = "dict_label", property = "warningNoticeTypeName"),
    })
    public List<RuleWarningNoticeType> getWarningNoticeTypeByruleId(@Param("id") Long id);

    @Select("select  emotion  from rule_emotion a left join  warning_rule b  on  a.rule_id=b.id   where   a.rule_id= #{id}")
    List<String> getEmotionByRuleId(@Param("id")Long id);

    @Select("select  media_type  from rule_media_type a left join  warning_rule b  on  a.rule_id=b.id   where   a.rule_id= #{id}")

    @Results({
            @Result(column = "media_type", property = "mediaType"),
    })
    List<String> getMediaTypeByRuleId(Long id);
}
